test was backward, so deprecated functions were excluded by default
authorHavoc Pennington <hp@redhat.com>
Mon, 19 Feb 2001 22:25:30 +0000 (22:25 +0000)
committerHavoc Pennington <hp@src.gnome.org>
Mon, 19 Feb 2001 22:25:30 +0000 (22:25 +0000)
2001-02-19  Havoc Pennington  <hp@redhat.com>

* gdk/gdkcolor.h: test was backward, so deprecated functions were
excluded by default

* gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
clean up the old code a bit

* gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
inconsistent state

* gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
draw inconsistent state

* gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
(create_menu): add inconsistent test

* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
new function
(gtk_check_menu_item_get_inconsistent): new function
(gtk_real_check_menu_item_draw_indicator): draw the inconsistent
state (using etched in for now)

* gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
draw inconsistent state

* gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
function, used when the user has selected a range of stuff in
different states
(gtk_toggle_button_get_inconsistent): accessor for that
(gtk_toggle_button_paint): draw inconsistent state (etched in?
don't know what else to do)

18 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdkcolor.h
gtk/gtkcheckbutton.c
gtk/gtkcheckmenuitem.c
gtk/gtkcheckmenuitem.h
gtk/gtkradiobutton.c
gtk/gtkradiomenuitem.c
gtk/gtkstyle.c
gtk/gtktogglebutton.c
gtk/gtktogglebutton.h
gtk/testgtk.c
tests/testgtk.c

index 557d3e2c289027361cac1d83e6c6f7c7a5960ada..edc4d8403fcfa241294bf7d6ed90f40a684adbc7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+2001-02-19  Havoc Pennington  <hp@redhat.com>
+
+       * gdk/gdkcolor.h: test was backward, so deprecated functions were
+       excluded by default
+
+       * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+       clean up the old code a bit
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+       inconsistent state
+
+       * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+       draw inconsistent state
+
+       * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+       (create_menu): add inconsistent test
+
+       * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+       new function
+       (gtk_check_menu_item_get_inconsistent): new function
+       (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+       state (using etched in for now)
+
+       * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+       draw inconsistent state
+
+       * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+       function, used when the user has selected a range of stuff in
+       different states
+       (gtk_toggle_button_get_inconsistent): accessor for that
+       (gtk_toggle_button_paint): draw inconsistent state (etched in?
+       don't know what else to do)
+
 2001-02-19  Hans Breuer <hans@breuer.org>
 
        * gtk/gtk.def : updated exported symbols
index 557d3e2c289027361cac1d83e6c6f7c7a5960ada..edc4d8403fcfa241294bf7d6ed90f40a684adbc7 100644 (file)
@@ -1,3 +1,36 @@
+2001-02-19  Havoc Pennington  <hp@redhat.com>
+
+       * gdk/gdkcolor.h: test was backward, so deprecated functions were
+       excluded by default
+
+       * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+       clean up the old code a bit
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+       inconsistent state
+
+       * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+       draw inconsistent state
+
+       * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+       (create_menu): add inconsistent test
+
+       * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+       new function
+       (gtk_check_menu_item_get_inconsistent): new function
+       (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+       state (using etched in for now)
+
+       * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+       draw inconsistent state
+
+       * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+       function, used when the user has selected a range of stuff in
+       different states
+       (gtk_toggle_button_get_inconsistent): accessor for that
+       (gtk_toggle_button_paint): draw inconsistent state (etched in?
+       don't know what else to do)
+
 2001-02-19  Hans Breuer <hans@breuer.org>
 
        * gtk/gtk.def : updated exported symbols
index 557d3e2c289027361cac1d83e6c6f7c7a5960ada..edc4d8403fcfa241294bf7d6ed90f40a684adbc7 100644 (file)
@@ -1,3 +1,36 @@
+2001-02-19  Havoc Pennington  <hp@redhat.com>
+
+       * gdk/gdkcolor.h: test was backward, so deprecated functions were
+       excluded by default
+
+       * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+       clean up the old code a bit
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+       inconsistent state
+
+       * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+       draw inconsistent state
+
+       * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+       (create_menu): add inconsistent test
+
+       * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+       new function
+       (gtk_check_menu_item_get_inconsistent): new function
+       (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+       state (using etched in for now)
+
+       * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+       draw inconsistent state
+
+       * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+       function, used when the user has selected a range of stuff in
+       different states
+       (gtk_toggle_button_get_inconsistent): accessor for that
+       (gtk_toggle_button_paint): draw inconsistent state (etched in?
+       don't know what else to do)
+
 2001-02-19  Hans Breuer <hans@breuer.org>
 
        * gtk/gtk.def : updated exported symbols
index 557d3e2c289027361cac1d83e6c6f7c7a5960ada..edc4d8403fcfa241294bf7d6ed90f40a684adbc7 100644 (file)
@@ -1,3 +1,36 @@
+2001-02-19  Havoc Pennington  <hp@redhat.com>
+
+       * gdk/gdkcolor.h: test was backward, so deprecated functions were
+       excluded by default
+
+       * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+       clean up the old code a bit
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+       inconsistent state
+
+       * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+       draw inconsistent state
+
+       * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+       (create_menu): add inconsistent test
+
+       * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+       new function
+       (gtk_check_menu_item_get_inconsistent): new function
+       (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+       state (using etched in for now)
+
+       * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+       draw inconsistent state
+
+       * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+       function, used when the user has selected a range of stuff in
+       different states
+       (gtk_toggle_button_get_inconsistent): accessor for that
+       (gtk_toggle_button_paint): draw inconsistent state (etched in?
+       don't know what else to do)
+
 2001-02-19  Hans Breuer <hans@breuer.org>
 
        * gtk/gtk.def : updated exported symbols
index 557d3e2c289027361cac1d83e6c6f7c7a5960ada..edc4d8403fcfa241294bf7d6ed90f40a684adbc7 100644 (file)
@@ -1,3 +1,36 @@
+2001-02-19  Havoc Pennington  <hp@redhat.com>
+
+       * gdk/gdkcolor.h: test was backward, so deprecated functions were
+       excluded by default
+
+       * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+       clean up the old code a bit
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+       inconsistent state
+
+       * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+       draw inconsistent state
+
+       * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+       (create_menu): add inconsistent test
+
+       * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+       new function
+       (gtk_check_menu_item_get_inconsistent): new function
+       (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+       state (using etched in for now)
+
+       * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+       draw inconsistent state
+
+       * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+       function, used when the user has selected a range of stuff in
+       different states
+       (gtk_toggle_button_get_inconsistent): accessor for that
+       (gtk_toggle_button_paint): draw inconsistent state (etched in?
+       don't know what else to do)
+
 2001-02-19  Hans Breuer <hans@breuer.org>
 
        * gtk/gtk.def : updated exported symbols
index 557d3e2c289027361cac1d83e6c6f7c7a5960ada..edc4d8403fcfa241294bf7d6ed90f40a684adbc7 100644 (file)
@@ -1,3 +1,36 @@
+2001-02-19  Havoc Pennington  <hp@redhat.com>
+
+       * gdk/gdkcolor.h: test was backward, so deprecated functions were
+       excluded by default
+
+       * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+       clean up the old code a bit
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+       inconsistent state
+
+       * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+       draw inconsistent state
+
+       * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+       (create_menu): add inconsistent test
+
+       * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+       new function
+       (gtk_check_menu_item_get_inconsistent): new function
+       (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+       state (using etched in for now)
+
+       * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+       draw inconsistent state
+
+       * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+       function, used when the user has selected a range of stuff in
+       different states
+       (gtk_toggle_button_get_inconsistent): accessor for that
+       (gtk_toggle_button_paint): draw inconsistent state (etched in?
+       don't know what else to do)
+
 2001-02-19  Hans Breuer <hans@breuer.org>
 
        * gtk/gtk.def : updated exported symbols
index 557d3e2c289027361cac1d83e6c6f7c7a5960ada..edc4d8403fcfa241294bf7d6ed90f40a684adbc7 100644 (file)
@@ -1,3 +1,36 @@
+2001-02-19  Havoc Pennington  <hp@redhat.com>
+
+       * gdk/gdkcolor.h: test was backward, so deprecated functions were
+       excluded by default
+
+       * gtk/gtkstyle.c (gtk_default_draw_diamond): draw etched in/out,
+       clean up the old code a bit
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_draw_indicator): draw
+       inconsistent state
+
+       * gtk/gtkradiomenuitem.c (gtk_radio_menu_item_draw_indicator):
+       draw inconsistent state
+
+       * gtk/testgtk.c (create_toggle_buttons): add test for inconsistent
+       (create_menu): add inconsistent test
+
+       * gtk/gtkcheckmenuitem.c (gtk_check_menu_item_set_inconsistent):
+       new function
+       (gtk_check_menu_item_get_inconsistent): new function
+       (gtk_real_check_menu_item_draw_indicator): draw the inconsistent
+       state (using etched in for now)
+
+       * gtk/gtkcheckbutton.c (gtk_real_check_button_draw_indicator):
+       draw inconsistent state
+
+       * gtk/gtktogglebutton.c (gtk_toggle_button_set_inconsistent): new
+       function, used when the user has selected a range of stuff in
+       different states
+       (gtk_toggle_button_get_inconsistent): accessor for that
+       (gtk_toggle_button_paint): draw inconsistent state (etched in?
+       don't know what else to do)
+
 2001-02-19  Hans Breuer <hans@breuer.org>
 
        * gtk/gtk.def : updated exported symbols
index e703b38d9da852c59bad3f0e6bdb7ba6586f8cac..8487ca36e8d54ec139a6b434e1bda544d9f642bf 100644 (file)
@@ -97,7 +97,7 @@ gboolean  gdk_color_equal (const GdkColor *colora,
                           const GdkColor *colorb);
 
 /* The following functions are deprecated */
-#ifdef GDK_DISABLE_DEPRECATED
+#ifndef GDK_DISABLE_DEPRECATED
 void gdk_colors_store   (GdkColormap   *colormap,
                          GdkColor      *colors,
                          gint           ncolors);
index 681082d7ecde1ea36f24c52c356bbeee805b384f..dc92a23c8d1d7e3fa185eea83e632f5d9a294914 100644 (file)
@@ -356,8 +356,13 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
       y = widget->allocation.y + (widget->allocation.height - GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size) / 2;
       width = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
       height = GTK_CHECK_BUTTON_GET_CLASS (widget)->indicator_size;
-      
-      if (GTK_TOGGLE_BUTTON (widget)->active)
+
+      if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
+        {
+          state_type = GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE ? GTK_STATE_NORMAL : GTK_WIDGET_STATE (widget);
+          shadow_type = GTK_SHADOW_ETCHED_IN;
+        }
+      else if (GTK_TOGGLE_BUTTON (widget)->active)
        {
          state_type = GTK_STATE_ACTIVE;
          shadow_type = GTK_SHADOW_IN;
index 09b37baf7972136591468ad12f8a977722ab350a..a7cabb7361c6934e222123908ad61cb5471b3685 100644 (file)
@@ -173,6 +173,52 @@ gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item)
   gtk_signal_emit (GTK_OBJECT (check_menu_item), check_menu_item_signals[TOGGLED]);
 }
 
+/**
+ * gtk_check_menu_item_set_inconsistent:
+ * @check_menu_item: a #GtkCheckMenuItem
+ * @setting: %TRUE to display an "inconsistent" third state check
+ *
+ * If the user has selected a range of elements (such as some text or
+ * spreadsheet cells) that are affected by a boolean setting, and the
+ * current values in that range are inconsistent, you may want to
+ * display the check in an "in between" state. This function turns on
+ * "in between" display.  Normally you would turn off the inconsistent
+ * state again if the user explicitly selects a setting. This has to be
+ * done manually, gtk_check_menu_item_set_inconsistent() only affects
+ * visual appearance, it doesn't affect the semantics of the widget.
+ * 
+ **/
+void
+gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
+                                      gboolean          setting)
+{
+  g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
+  
+  setting = setting != FALSE;
+
+  if (setting != check_menu_item->inconsistent)
+    {
+      check_menu_item->inconsistent = setting;
+      gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
+    }
+}
+
+/**
+ * gtk_check_menu_item_get_inconsistent:
+ * @check_menu_item: a #GtkCheckMenuItem
+ * 
+ * Retrieves the value set by gtk_check_menu_item_set_inconsistent().
+ * 
+ * Return value: %TRUE if inconsistent
+ **/
+gboolean
+gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item)
+{
+  g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
+
+  return check_menu_item->inconsistent;
+}
+
 static void
 gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
 {
@@ -265,7 +311,14 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
                  (state_type == GTK_STATE_PRELIGHT))
                shadow_type = GTK_SHADOW_OUT;
            }
-         
+
+          if (check_menu_item->inconsistent)
+            {
+              shadow_type = GTK_SHADOW_ETCHED_IN;
+              if (state_type == GTK_STATE_ACTIVE)
+                state_type = GTK_STATE_NORMAL;
+            }
+              
          gtk_paint_check (widget->style, widget->window,
                           state_type, shadow_type,
                           area, widget, "check",
index 4142fe903041b1012eaa9429b2aeeebf4e1ccf19..010088c366fd39c0669004e6a35f82416970dcd8 100644 (file)
@@ -54,6 +54,7 @@ struct _GtkCheckMenuItem
   
   guint active : 1;
   guint always_show_toggle : 1;
+  guint inconsistent : 1;
 };
 
 struct _GtkCheckMenuItemClass
@@ -75,6 +76,10 @@ void    gtk_check_menu_item_set_show_toggle (GtkCheckMenuItem *menu_item,
                                                gboolean          always);
 void      gtk_check_menu_item_toggled         (GtkCheckMenuItem *check_menu_item);
 
+void       gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
+                                                 gboolean          setting);
+gboolean   gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item);
+
 
 #ifdef __cplusplus
 }
index 093993aea77c81b0b27b38d6b37031926da5755b..e231f51f95e0c42aa68e7f675ad3e83c8d6c6555 100644 (file)
@@ -416,6 +416,9 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
        shadow_type = GTK_SHADOW_IN;
       else
        shadow_type = GTK_SHADOW_OUT;
+
+      if (GTK_TOGGLE_BUTTON (widget)->inconsistent)
+        shadow_type = GTK_SHADOW_ETCHED_IN;
       
       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
        x = widget->allocation.x + widget->allocation.width - (width + x - widget->allocation.x);
index a8b2ac3207a0d0fda87569ee1286a3dc80b074a2..27db681dcb298b43f0b0c22a29da2b2264fc9c97 100644 (file)
@@ -298,6 +298,9 @@ gtk_radio_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
          else
            shadow_type = GTK_SHADOW_OUT;
 
+          if (check_menu_item->inconsistent)
+            shadow_type = GTK_SHADOW_ETCHED_IN;
+          
          gtk_paint_option (widget->style, widget->window,
                            state_type, shadow_type,
                            area, widget, "option",
index 3469c74cdc8388236b0a35d40824c840f38d3be2..20013e4f5614678e93b3cdd838b7f627d1b74346 100644 (file)
@@ -2229,6 +2229,18 @@ gtk_default_draw_diamond (GtkStyle      *style,
 {
   gint half_width;
   gint half_height;
+  GdkGC *outer_nw = NULL;
+  GdkGC *outer_ne = NULL;
+  GdkGC *outer_sw = NULL;
+  GdkGC *outer_se = NULL;
+  GdkGC *middle_nw = NULL;
+  GdkGC *middle_ne = NULL;
+  GdkGC *middle_sw = NULL;
+  GdkGC *middle_se = NULL;
+  GdkGC *inner_nw = NULL;
+  GdkGC *inner_ne = NULL;
+  GdkGC *inner_sw = NULL;
+  GdkGC *inner_se = NULL;
   
   g_return_if_fail (GTK_IS_STYLE (style));
   g_return_if_fail (window != NULL);
@@ -2250,89 +2262,91 @@ gtk_default_draw_diamond (GtkStyle      *style,
       gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
       gdk_gc_set_clip_rectangle (style->black_gc, area);
     }
+  
   switch (shadow_type)
     {
     case GTK_SHADOW_IN:
-      gdk_draw_line (window, style->bg_gc[state_type],
-                     x + 2, y + half_height,
-                     x + half_width, y + height - 2);
-      gdk_draw_line (window, style->bg_gc[state_type],
-                     x + half_width, y + height - 2,
-                     x + width - 2, y + half_height);
-      gdk_draw_line (window, style->light_gc[state_type],
-                     x + 1, y + half_height,
-                     x + half_width, y + height - 1);
-      gdk_draw_line (window, style->light_gc[state_type],
-                     x + half_width, y + height - 1,
-                     x + width - 1, y + half_height);
-      gdk_draw_line (window, style->light_gc[state_type],
-                     x, y + half_height,
-                     x + half_width, y + height);
-      gdk_draw_line (window, style->light_gc[state_type],
-                     x + half_width, y + height,
-                     x + width, y + half_height);
-      
-      gdk_draw_line (window, style->black_gc,
-                     x + 2, y + half_height,
-                     x + half_width, y + 2);
-      gdk_draw_line (window, style->black_gc,
-                     x + half_width, y + 2,
-                     x + width - 2, y + half_height);
-      gdk_draw_line (window, style->dark_gc[state_type],
-                     x + 1, y + half_height,
-                     x + half_width, y + 1);
-      gdk_draw_line (window, style->dark_gc[state_type],
-                     x + half_width, y + 1,
-                     x + width - 1, y + half_height);
-      gdk_draw_line (window, style->dark_gc[state_type],
-                     x, y + half_height,
-                     x + half_width, y);
-      gdk_draw_line (window, style->dark_gc[state_type],
-                     x + half_width, y,
-                     x + width, y + half_height);
+      inner_sw = inner_se = style->bg_gc[state_type];
+      middle_sw = middle_se = style->light_gc[state_type];
+      outer_sw = outer_se = style->light_gc[state_type];
+      inner_nw = inner_ne = style->black_gc;
+      middle_nw = middle_ne = style->dark_gc[state_type];
+      outer_nw = outer_ne = style->dark_gc[state_type];
       break;
+          
     case GTK_SHADOW_OUT:
-      gdk_draw_line (window, style->dark_gc[state_type],
+      inner_sw = inner_se = style->dark_gc[state_type];
+      middle_sw = middle_se = style->dark_gc[state_type];
+      outer_sw = outer_se = style->black_gc;
+      inner_nw = inner_ne = style->bg_gc[state_type];
+      middle_nw = middle_ne = style->light_gc[state_type];
+      outer_nw = outer_ne = style->light_gc[state_type];
+      break;
+
+    case GTK_SHADOW_ETCHED_IN:
+      inner_sw = inner_se = style->bg_gc[state_type];
+      middle_sw = middle_se = style->dark_gc[state_type];
+      outer_sw = outer_se = style->light_gc[state_type];
+      inner_nw = inner_ne = style->bg_gc[state_type];
+      middle_nw = middle_ne = style->light_gc[state_type];
+      outer_nw = outer_ne = style->dark_gc[state_type];
+      break;
+
+    case GTK_SHADOW_ETCHED_OUT:
+      inner_sw = inner_se = style->bg_gc[state_type];
+      middle_sw = middle_se = style->light_gc[state_type];
+      outer_sw = outer_se = style->dark_gc[state_type];
+      inner_nw = inner_ne = style->bg_gc[state_type];
+      middle_nw = middle_ne = style->dark_gc[state_type];
+      outer_nw = outer_ne = style->light_gc[state_type];
+      break;
+      
+    default:
+
+      break;
+    }
+
+  if (inner_sw)
+    {
+      gdk_draw_line (window, inner_sw,
                      x + 2, y + half_height,
                      x + half_width, y + height - 2);
-      gdk_draw_line (window, style->dark_gc[state_type],
+      gdk_draw_line (window, inner_se,
                      x + half_width, y + height - 2,
                      x + width - 2, y + half_height);
-      gdk_draw_line (window, style->dark_gc[state_type],
+      gdk_draw_line (window, middle_sw,
                      x + 1, y + half_height,
                      x + half_width, y + height - 1);
-      gdk_draw_line (window, style->dark_gc[state_type],
+      gdk_draw_line (window, middle_se,
                      x + half_width, y + height - 1,
                      x + width - 1, y + half_height);
-      gdk_draw_line (window, style->black_gc,
+      gdk_draw_line (window, outer_sw,
                      x, y + half_height,
                      x + half_width, y + height);
-      gdk_draw_line (window, style->black_gc,
+      gdk_draw_line (window, outer_se,
                      x + half_width, y + height,
                      x + width, y + half_height);
-      
-      gdk_draw_line (window, style->bg_gc[state_type],
+  
+      gdk_draw_line (window, inner_nw,
                      x + 2, y + half_height,
                      x + half_width, y + 2);
-      gdk_draw_line (window, style->bg_gc[state_type],
+      gdk_draw_line (window, inner_ne,
                      x + half_width, y + 2,
                      x + width - 2, y + half_height);
-      gdk_draw_line (window, style->light_gc[state_type],
+      gdk_draw_line (window, middle_nw,
                      x + 1, y + half_height,
                      x + half_width, y + 1);
-      gdk_draw_line (window, style->light_gc[state_type],
+      gdk_draw_line (window, middle_ne,
                      x + half_width, y + 1,
                      x + width - 1, y + half_height);
-      gdk_draw_line (window, style->light_gc[state_type],
+      gdk_draw_line (window, outer_nw,
                      x, y + half_height,
                      x + half_width, y);
-      gdk_draw_line (window, style->light_gc[state_type],
+      gdk_draw_line (window, outer_ne,
                      x + half_width, y,
                      x + width, y + half_height);
-      break;
-    default:
-      break;
     }
+  
   if (area)
     {
       gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL);
index c1bb468562f55ac63de097d09496267cd049651e..e51ee8400f5b2c524980e888c45b97656f25a96e 100644 (file)
@@ -305,6 +305,51 @@ gtk_toggle_button_toggled (GtkToggleButton *toggle_button)
   gtk_signal_emit (GTK_OBJECT (toggle_button), toggle_button_signals[TOGGLED]);
 }
 
+/**
+ * gtk_toggle_button_set_inconsistent:
+ * @toggle_button: a #GtkToggleButton
+ * @setting: %TRUE if state is inconsistent
+ *
+ * If the user has selected a range of elements (such as some text or
+ * spreadsheet cells) that are affected by a toggle button, and the
+ * current values in that range are inconsistent, you may want to
+ * display the toggle in an "in between" state. This function turns on
+ * "in between" display.  Normally you would turn off the inconsistent
+ * state again if the user toggles the toggle button. This has to be
+ * done manually, gtk_toggle_button_set_inconsistent() only affects
+ * visual appearance, it doesn't affect the semantics of the button.
+ * 
+ **/
+void
+gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
+                                    gboolean         setting)
+{
+  g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button));
+  
+  setting = setting != FALSE;
+
+  if (setting != toggle_button->inconsistent)
+    {
+      toggle_button->inconsistent = setting;
+      gtk_widget_queue_draw (GTK_WIDGET (toggle_button));
+    }
+}
+
+/**
+ * gtk_toggle_button_get_inconsistent:
+ * @toggle_button: a #GtkToggleButton
+ * 
+ * Gets the value set by gtk_toggle_button_set_inconsistent().
+ * 
+ * Return value: %TRUE if the button is displayed as inconsistent, %FALSE otherwise
+ **/
+gboolean
+gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button)
+{
+  g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button), FALSE);
+
+  return toggle_button->inconsistent;
+}
 
 static void
 gtk_toggle_button_paint (GtkWidget    *widget,
@@ -313,6 +358,7 @@ gtk_toggle_button_paint (GtkWidget    *widget,
   GtkButton *button;
   GtkToggleButton *toggle_button;
   GtkShadowType shadow_type;
+  GtkStateType state_type;
   gint width, height;
   gint x, y;
 
@@ -356,9 +402,17 @@ gtk_toggle_button_paint (GtkWidget    *widget,
          height -= 2;
        }
 
-      if ((GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) ||
+      state_type = GTK_WIDGET_STATE (widget);
+      
+      if (toggle_button->inconsistent)
+        {
+          if (state_type == GTK_STATE_ACTIVE)
+            state_type = GTK_STATE_NORMAL;
+          shadow_type = GTK_SHADOW_ETCHED_IN;
+        }
+      else if ((GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE) ||
          toggle_button->active)
-       shadow_type = GTK_SHADOW_IN;
+        shadow_type = GTK_SHADOW_IN;
       else
        shadow_type = GTK_SHADOW_OUT;
       
@@ -366,7 +420,7 @@ gtk_toggle_button_paint (GtkWidget    *widget,
          (GTK_WIDGET_STATE(widget) != GTK_STATE_NORMAL &&
           GTK_WIDGET_STATE(widget) != GTK_STATE_INSENSITIVE))
        gtk_paint_box (widget->style, widget->window,
-                      GTK_WIDGET_STATE (widget),
+                       state_type,
                       shadow_type, area, widget, "togglebutton",
                       x, y, width, height);
       
index def107e5acb29d193325c23712f42c3943bdad5e..c00b98bad5ade38414e2162c79498125c1ef76b3 100644 (file)
@@ -54,6 +54,7 @@ struct _GtkToggleButton
 
   guint active : 1;
   guint draw_indicator : 1;
+  guint inconsistent : 1;
   
   GdkWindow *event_window;
 };
@@ -76,6 +77,9 @@ void       gtk_toggle_button_set_active     (GtkToggleButton *toggle_button,
 gboolean   gtk_toggle_button_get_active            (GtkToggleButton *toggle_button);
 void       gtk_toggle_button_toggled        (GtkToggleButton *toggle_button);
 
+void       gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button,
+                                               gboolean         setting);
+gboolean   gtk_toggle_button_get_inconsistent (GtkToggleButton *toggle_button);
 
 #ifdef __cplusplus
 }
index 97bf5e270d26836f0f4d5c870e05f39068a41658..41374de05b065f383c09814a7ae95f0a965c52c5 100644 (file)
@@ -316,6 +316,10 @@ create_toggle_buttons (void)
       button = gtk_toggle_button_new_with_label ("button3");
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
+      button = gtk_toggle_button_new_with_label ("inconsistent");
+      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
@@ -378,6 +382,10 @@ create_check_buttons (void)
       button = gtk_check_button_new_with_label ("button3");
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
+      button = gtk_check_button_new_with_label ("inconsistent");
+      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
@@ -445,6 +453,12 @@ create_radio_buttons (void)
                 "button3");
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
+      button = gtk_radio_button_new_with_label (
+                 gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
+                "inconsistent");
+      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
@@ -2788,15 +2802,22 @@ create_menu (gint depth, gint length, gboolean tearoff)
   for (i = 0, j = 1; i < length; i++, j++)
     {
       sprintf (buf, "item %2d - %d", depth, j);
+
       menuitem = gtk_radio_menu_item_new_with_label (group, buf);
       group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
+
       if (depth % 2)
        gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
+
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
       gtk_widget_show (menuitem);
       if (i == 3)
        gtk_widget_set_sensitive (menuitem, FALSE);
 
+      if (i == 5)
+        gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (menuitem),
+                                              TRUE);
+
       if (i < 5)
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, 5,  TRUE));
     }
index 97bf5e270d26836f0f4d5c870e05f39068a41658..41374de05b065f383c09814a7ae95f0a965c52c5 100644 (file)
@@ -316,6 +316,10 @@ create_toggle_buttons (void)
       button = gtk_toggle_button_new_with_label ("button3");
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
+      button = gtk_toggle_button_new_with_label ("inconsistent");
+      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
@@ -378,6 +382,10 @@ create_check_buttons (void)
       button = gtk_check_button_new_with_label ("button3");
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
+      button = gtk_check_button_new_with_label ("inconsistent");
+      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
@@ -445,6 +453,12 @@ create_radio_buttons (void)
                 "button3");
       gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
 
+      button = gtk_radio_button_new_with_label (
+                 gtk_radio_button_group (GTK_RADIO_BUTTON (button)),
+                "inconsistent");
+      gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (button), TRUE);
+      gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
+      
       separator = gtk_hseparator_new ();
       gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
 
@@ -2788,15 +2802,22 @@ create_menu (gint depth, gint length, gboolean tearoff)
   for (i = 0, j = 1; i < length; i++, j++)
     {
       sprintf (buf, "item %2d - %d", depth, j);
+
       menuitem = gtk_radio_menu_item_new_with_label (group, buf);
       group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (menuitem));
+
       if (depth % 2)
        gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menuitem), TRUE);
+
       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
       gtk_widget_show (menuitem);
       if (i == 3)
        gtk_widget_set_sensitive (menuitem, FALSE);
 
+      if (i == 5)
+        gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (menuitem),
+                                              TRUE);
+
       if (i < 5)
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (depth - 1, 5,  TRUE));
     }